#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QList>
#include <QMdiSubWindow>
  #include <QSignalMapper>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MyTextEdit;
class MainWindow : public QMainWindow
{
    Q_OBJECT
public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    void createEdit(QString filePath = "", bool existed = false);
    MyTextEdit * isExistedWindow(QString filePath);
    bool eventFilter(QObject *object, QEvent *event);
    void deleteWindow(QString filePath);
    void updateWindowMenu();
    void setActiveWindow(QObject *obj);
    void clearOffset();
    void showCursorPos();
protected:
    void closeEvent(QCloseEvent *event);

private slots:
    void on_actionNew_triggered();

    void on_actionSave_triggered();

    void on_actionSaveAs_triggered();
    void on_actionOpen_triggered();
    void activeChanged(QMdiSubWindow * subWindow);

    void on_actionUndo_triggered();

    void on_actionRedo_triggered();

    void on_actionCut_triggered();

    void on_actionCopy_triggered();

    void on_actionPaste_triggered();

    void on_actionClose_triggered();


    void on_actionNext_triggered();

    void on_actionPrevious_triggered();

    void on_actionCloseAll_triggered();

    void on_actionTile_triggered();

    void on_actionCascade_triggered();
    void on_actionAbout_triggered();
    void on_actionAboutQt_triggered();

private:
    void readSettings();
    void writeSettings();
    void initWindow();
    Ui::MainWindow *ui;
    QList<MyTextEdit *> *editWindowList;
    MyTextEdit * activeSubWindow;
    QSignalMapper *windowMapper;
    int offset = 0;
    QString lastTime;
};
#endif // MAINWINDOW_H
